package com.noshufou.android.su.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import com.noshufou.android.su.R.styleable;

public class SlidingPanel extends ViewGroup
{
  private View mAnchor;
  private int mAnchorId;
  private boolean mAnimating = false;
  private View mButton;
  private int mButtonId;
  private int mClosedLimit;
  private View mContent;
  private int mContentId;
  private boolean mExpanded = true;
  private int mFillOffset = 0;
  private int mOpenOverlap;

  public SlidingPanel(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }

  public SlidingPanel(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.SlidingPanel, paramInt, 0);
    int i = localTypedArray.getResourceId(0, 0);
    if (i == 0)
      throw new IllegalArgumentException("The button attribute is required and must refer to a valid child");
    int j = localTypedArray.getResourceId(1, 0);
    if (j == i)
      throw new IllegalArgumentException("The anchor attribute is required and must refer to a different child");
    int k = localTypedArray.getResourceId(2, 0);
    if ((k == j) || (k == i))
      throw new IllegalArgumentException("The content attribute is required and must refer to a different child");
    this.mOpenOverlap = localTypedArray.getDimensionPixelSize(3, 0);
    this.mClosedLimit = localTypedArray.getDimensionPixelSize(4, 0);
    localTypedArray.recycle();
    this.mButtonId = i;
    this.mAnchorId = j;
    this.mContentId = k;
  }

  protected void onFinishInflate()
  {
    this.mButton = findViewById(this.mButtonId);
    if (this.mButton == null)
      throw new IllegalArgumentException("The handle attribute must refer to a child");
    this.mAnchor = findViewById(this.mAnchorId);
    if (this.mAnchor == null)
      throw new IllegalArgumentException("The anchor attribute must refer to a child");
    this.mContent = findViewById(this.mContentId);
    if (this.mContent == null)
      throw new IllegalArgumentException("The content attribute must refer to a child");
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    View localView1 = this.mButton;
    localView1.layout(0, 0, localView1.getMeasuredWidth(), localView1.getMeasuredHeight());
    View localView2 = this.mAnchor;
    localView2.layout(0, localView1.getMeasuredHeight(), localView2.getMeasuredWidth(), localView1.getMeasuredHeight() + localView2.getMeasuredHeight());
    View localView3 = this.mContent;
    int i;
    if (this.mAnimating)
      i = localView3.getLeft();
    while (true)
    {
      localView3.layout(i, 0, i + localView3.getMeasuredWidth(), localView3.getMeasuredHeight());
      return;
      if (this.mExpanded)
      {
        i = this.mClosedLimit;
        continue;
      }
      i = localView2.getRight() - this.mOpenOverlap;
    }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    int i = View.resolveSize(0, paramInt1);
    int j = View.resolveSize(0, paramInt2);
    View localView1 = this.mAnchor;
    measureChild(localView1, paramInt1, paramInt2);
    View localView2 = this.mButton;
    measureChild(localView2, View.MeasureSpec.makeMeasureSpec(localView1.getMeasuredWidth(), 1073741824), paramInt2);
    localView2.setOnClickListener(new Toggler(null));
    this.mContent.measure(View.MeasureSpec.makeMeasureSpec(i - this.mClosedLimit, 1073741824), View.MeasureSpec.makeMeasureSpec(j, 1073741824));
    setMeasuredDimension(i, j);
  }

  public void toggle()
  {
    View localView = this.mContent;
    int i = this.mAnchor.getMeasuredWidth() - this.mOpenOverlap - this.mClosedLimit;
    TranslateAnimation localTranslateAnimation;
    if (this.mExpanded)
    {
      localTranslateAnimation = new TranslateAnimation(0.0F, i, 0.0F, 0.0F);
      this.mFillOffset = i;
      if (!this.mExpanded)
        break label134;
    }
    label134: for (boolean bool = false; ; bool = true)
    {
      this.mExpanded = bool;
      localTranslateAnimation.setFillEnabled(true);
      localTranslateAnimation.setFillBefore(true);
      localTranslateAnimation.setDuration(300L);
      localTranslateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
      localTranslateAnimation.setAnimationListener(new AnimationFiller(null));
      localView.startAnimation(localTranslateAnimation);
      return;
      localTranslateAnimation = new TranslateAnimation(0.0F, -i, 0.0F, 0.0F);
      this.mFillOffset = (-i);
      break;
    }
  }

  private class AnimationFiller
    implements Animation.AnimationListener
  {
    private AnimationFiller()
    {
    }

    public void onAnimationEnd(Animation paramAnimation)
    {
      SlidingPanel.this.mAnimating = false;
      SlidingPanel.this.mContent.offsetLeftAndRight(SlidingPanel.this.mFillOffset);
      Button localButton = (Button)SlidingPanel.this.mButton;
      if (SlidingPanel.this.mExpanded)
        localButton.setText(">");
      while (true)
      {
        return;
        localButton.setText("<");
      }
    }

    public void onAnimationRepeat(Animation paramAnimation)
    {
    }

    public void onAnimationStart(Animation paramAnimation)
    {
      SlidingPanel.this.mAnimating = true;
    }
  }

  private class Toggler
    implements View.OnClickListener
  {
    private Toggler()
    {
    }

    public void onClick(View paramView)
    {
      if (!SlidingPanel.this.mAnimating)
        SlidingPanel.this.toggle();
    }
  }
}

/* Location:           D:\Development\Decompile_Workspace\슈퍼유저-41\classes_dex2jar.jar
 * Qualified Name:     com.noshufou.android.su.widget.SlidingPanel
 * JD-Core Version:    0.6.0
 */